package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.bifang.engine.protect.core.annotation.NoSignCrypto;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.eduSjtj02.EduSjtj02InVO;
import com.jwsoft.manager.common.vo.eduSjtj02.EduSjtj02KeyVO;
import com.jwsoft.manager.common.vo.eduSjtj02.EduSjtj02QueryVO;
import com.jwsoft.manager.common.vo.eduSjtj02.EduSjtj02VO;
import com.jwsoft.manager.core.integration.EduSjtj02Integration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * 数据统计02网关
 *
 * @author linyh
 * @since 2023-04-21
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "数据统计02", description = "数据统计02")
public class EduSjtj02Controller {

    @Autowired
    public EduSjtj02Integration eduSjtj02Integration;

    @Operation(summary = "数据统计02分页查询",description = "数据统计02分页查询")
    @PostMapping(value = "/eduSjtj020001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduSjtj02VO>> getList(@RequestBody @Validated EduSjtj02QueryVO vo) {
        return AppResponse.successData(eduSjtj02Integration.getList(vo));
    }

    @Operation(summary = "数据统计02根据主键查询详情",description = "数据统计02根据主键查询详情")
    @PostMapping(value = "/eduSjtj020002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSjtj02VO> getById(@RequestBody @Validated EduSjtj02KeyVO vo) {
        return AppResponse.successData(eduSjtj02Integration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "数据统计02新增",description = "数据统计02新增")
    @PostMapping(value = "/eduSjtj020004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSjtj02VO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduSjtj02VO vo) {
        return AppResponse.successData(eduSjtj02Integration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "数据统计02修改",description = "数据统计02修改")
    @PostMapping(value = "/eduSjtj020005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSjtj02VO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduSjtj02VO vo) {
        return AppResponse.successData(eduSjtj02Integration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "数据统计02删除",description = "数据统计02删除")
    @PostMapping(value = "/eduSjtj020006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduSjtj02KeyVO vo) {
        eduSjtj02Integration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "生成数据统计02表数据",description = "生成数据统计02表数据")
    @PostMapping(value = "/eduSjtj020007", produces = "application/json;charset=UTF-8")
    public AppResponse saveEduSjtj02(@RequestBody @Validated EduSjtj02InVO vo) {
        eduSjtj02Integration.saveEduSjtj02(vo);
        return AppResponse.successMsg("数据生成成功！");
    }

    @Idempotent(expire="PT10S") //2秒内防重复提交
    @Operation(summary = "学校报名预测情况统计excel导出",description = "幼儿园报名管理excel导出")
    @PostMapping(value = "/eduSjtj020008", produces = "application/json;charset=UTF-8")
    @NoSignCrypto
    public void downloadData(@RequestBody @Validated EduSjtj02QueryVO vo, HttpServletResponse response) {
        eduSjtj02Integration.downloadData(vo,response);
    }
}
